package com.treasure.hunt.popup

import android.content.Context
import android.view.View
import android.view.animation.Animation
import android.view.animation.TranslateAnimation
import com.blankj.utilcode.util.BarUtils
import com.treasure.hunt.R
import kotlinx.android.synthetic.main.include_guide_1.view.*
import kotlinx.android.synthetic.main.include_guide_2.view.*
import kotlinx.android.synthetic.main.include_guide_3.view.*
import kotlinx.android.synthetic.main.include_guide_4.view.*
import kotlinx.android.synthetic.main.include_guide_5.view.*
import kotlinx.android.synthetic.main.include_guide_6.view.*
import kotlinx.android.synthetic.main.popup_dialog_guide.view.*
import razerdp.basepopup.BasePopupWindow

class DialogGuidePopup(
    context: Context, val onClick: (view: View) -> Unit
) : BasePopupWindow(context) {

    init {
//        setBlurBackgroundEnable(true)
        setOutSideDismiss(false)
        setBackPressEnable(false)
        setOverlayNavigationBar(false)
        setBackground(0)
    }

    override fun onCreateContentView(): View {
        return createPopupById(R.layout.popup_dialog_guide)
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)

        BarUtils.addMarginTopEqualStatusBarHeight(contentView.clDialogGuideHint6)

        contentView.llDialogGuideBottom1.setOnClickListener {
            setDialogGuideBottom1Click()
            onClick(it)
        }

        contentView.llDialogGuideBottom2.setOnClickListener {
            setDialogGuideBottom2Click()
            onClick(it)
        }

        contentView.llDialogGuideBottom3.setOnClickListener {
            setDialogGuideBottom3Click()
        }

        contentView.flDialogGuideTask.setOnClickListener {
            setDialogGuideTaskClick()
            onClick(it)
        }

        contentView.llDialogGuideBottom4.setOnClickListener {
            setDialogGuideBottom4Click()
            onClick(it)
        }

        contentView.flDialogGuideCard.setOnClickListener {
            onClick(it)
        }

    }

    private fun setDialogGuideBottom1Click() {
        contentView.includeGuide1.visibility = View.INVISIBLE
        contentView.includeGuide2.visibility = View.VISIBLE
        contentView.includeGuide3.visibility = View.INVISIBLE
        contentView.includeGuide4.visibility = View.INVISIBLE
        contentView.includeGuide5.visibility = View.INVISIBLE
        contentView.includeGuide6.visibility = View.INVISIBLE
    }

    private fun setDialogGuideBottom2Click() {
        contentView.includeGuide1.visibility = View.INVISIBLE
        contentView.includeGuide2.visibility = View.INVISIBLE
        contentView.includeGuide3.visibility = View.VISIBLE
        contentView.includeGuide4.visibility = View.INVISIBLE
        contentView.includeGuide5.visibility = View.INVISIBLE
        contentView.includeGuide6.visibility = View.INVISIBLE
    }

    private fun setDialogGuideBottom3Click() {
        contentView.includeGuide1.visibility = View.INVISIBLE
        contentView.includeGuide2.visibility = View.INVISIBLE
        contentView.includeGuide3.visibility = View.INVISIBLE
        contentView.includeGuide4.visibility = View.VISIBLE
        contentView.includeGuide5.visibility = View.INVISIBLE
        contentView.includeGuide6.visibility = View.INVISIBLE
    }

    private fun setDialogGuideTaskClick() {
        contentView.includeGuide1.visibility = View.INVISIBLE
        contentView.includeGuide2.visibility = View.INVISIBLE
        contentView.includeGuide3.visibility = View.INVISIBLE
        contentView.includeGuide4.visibility = View.INVISIBLE
        contentView.includeGuide5.visibility = View.VISIBLE
        contentView.includeGuide6.visibility = View.INVISIBLE
    }

    private fun setDialogGuideBottom4Click() {
        contentView.includeGuide1.visibility = View.INVISIBLE
        contentView.includeGuide2.visibility = View.INVISIBLE
        contentView.includeGuide3.visibility = View.INVISIBLE
        contentView.includeGuide4.visibility = View.INVISIBLE
        contentView.includeGuide5.visibility = View.INVISIBLE
        contentView.includeGuide6.visibility = View.VISIBLE
    }
}